package online.xuping.common;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;

/**
 * 用户简单的产生ID
 */
public class IdUtils {


    public static Snowflake snowflake;

    public static Snowflake getSnowflake(){
        if(snowflake==null){
            return IdUtil.getSnowflake();
        }else {
            return snowflake;
        }
    }

    /**
     * 获取雪花ID
     * @return
     */
    public static Long newId(){
        return getSnowflake().nextId();
    }


    public static String newId2(){
        return DateUtil.today()+  " - "+getSnowflake().nextId();
    }
}
